package com.weipai.education.dao.impl;

import com.weipai.education.dao.SystemDao;
import com.weipai.education.mapper.DocumentMapper;
import com.weipai.education.mapper.MessageMapper;
import com.weipai.education.mapper.PictureMapper;
import com.weipai.education.model.Document;
import com.weipai.education.model.Message;
import com.weipai.education.model.Picture;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: 曹朋飞
 * @Date: 2018/12/11 14:17
 */
@Repository
public class SystemDaoDaoImpl implements SystemDao {

    @Autowired
    private PictureMapper pictureMapper;
    @Autowired
    private DocumentMapper documentMapper;
    @Autowired
    private MessageMapper messageMapper;

    @Override
    public List<Map<String, Object>> pictureList(Integer start, Integer size) {
        return pictureMapper.pictureList(start, size);
    }

    @Override
    public Integer pictureListAmount() {
        return pictureMapper.pictureListAmount();
    }

    @Override
    public int updatePicture(Picture picture) {
        return pictureMapper.updateByPrimaryKeySelective(picture);
    }

    @Override
    public int insertPicture(Picture picture) {
        return pictureMapper.insert(picture);
    }

    @Override
    public Picture selectPictureByPrimaryKey(String id) {
        return pictureMapper.selectByPrimaryKey(Integer.parseInt(id));
    }

    @Override
    public int batchDeleteById(String[] id) {
        return pictureMapper.batchDeleteById(id);
    }

    @Override
    public int updateDocument(Document document) {
        return documentMapper.updateByPrimaryKeySelective(document);
    }

    @Override
    public int insertDocument(Document document) {
        return documentMapper.insert(document);
    }

    @Override
    public Document selectDocumentByPrimaryKey(Integer id) {
        return documentMapper.selectByPrimaryKey(id);
    }

    @Override
    public Integer insertMsg(Message message) {
        return messageMapper.insert(message);
    }

    @Override
    public List<Map<String, Object>> selectAllMessage(Integer userId) {
        return messageMapper.selectAll(userId);
    }

    @Override
    public Integer getMessageNum(Integer userId) {
        return messageMapper.getMessageNum(userId);
    }

    @Override
    public Integer changeMessageStatus(Integer messageId) {
        return messageMapper.changeMessageStatus(messageId);
    }


}
